package com.jews.example.demo.domain.user.mapper;

import com.jews.common.mapper.DateMapper;
import com.jews.common.mapper.GenericEnumMapper;
import com.jews.example.demo.domain.user.User;
import com.jews.example.demo.domain.user.creator.UserCreator;
import com.jews.example.demo.domain.user.query.UserQuery;
import com.jews.example.demo.domain.user.request.UserCreateRequest;
import com.jews.example.demo.domain.user.request.UserQueryRequest;
import com.jews.example.demo.domain.user.request.UserUpdateRequest;
import com.jews.example.demo.domain.user.response.UserResponse;
import com.jews.example.demo.domain.user.updater.UserUpdater;
import com.jews.example.demo.domain.user.vo.UserVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * mapstruct对象字段映射
 *
 * @author JewsChen
 * @title: UserMapper
 * @date 2022/11/29 23:48
 */
@Mapper(
        uses = {
                GenericEnumMapper.class,
                DateMapper.class
        }
)
public interface UserMapper {
    UserMapper INSTANCE = Mappers.getMapper(UserMapper.class);

    User dtoToEntity(UserCreator creator);

    UserUpdater request2Updater(UserUpdateRequest request);

    UserCreator request2Dto(UserCreateRequest request);

    UserQuery request2Query(UserQueryRequest request);

    UserResponse vo2Response(UserVO vo);

    default UserResponse vo2CustomResponse(UserVO vo) {
        UserResponse response = vo2Response(vo);
        return response;
    }
}
